package com.cxhc.app.api;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cxhc.system.domain.app.RpBaseCheck;
import com.cxhc.system.service.app.IRpBaseCheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.utils.poi.ExcelUtil;
import com.cxhc.common.core.page.TableDataInfo;

/**
 * 市政检查Controller
 * 
 * @author Dhq
 * @date 2024-09-25
 */
@RestController
@RequestMapping("/api/baseCheck")
public class ApiRpBaseCheck extends BaseController
{
    @Autowired
    private IRpBaseCheckService rpBaseCheckService;

    /**
     * 查询市政检查列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RpBaseCheck rpBaseCheck)
    {
        startPage();
        List<RpBaseCheck> list = rpBaseCheckService.selectRpBaseCheckList(rpBaseCheck);
        return getDataTable(list);
    }

    /**
     * 导出市政检查列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, RpBaseCheck rpBaseCheck)
    {
        List<RpBaseCheck> list = rpBaseCheckService.selectRpBaseCheckList(rpBaseCheck);
        ExcelUtil<RpBaseCheck> util = new ExcelUtil<RpBaseCheck>(RpBaseCheck.class);
        util.exportExcel(response, list, "市政检查数据");
    }

    /**
     * 获取市政检查详细信息
     */
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rpBaseCheckService.selectRpBaseCheckById(id));
    }

    /**
     * 新增市政检查
     */
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody RpBaseCheck rpBaseCheck)
    {
        return toAjax(rpBaseCheckService.insertRpBaseCheck(rpBaseCheck));
    }

    /**
     * 修改市政检查
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody RpBaseCheck rpBaseCheck)
    {
        return toAjax(rpBaseCheckService.updateRpBaseCheck(rpBaseCheck));
    }

    /**
     * 删除市政检查
     */
    @GetMapping(value = "/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(rpBaseCheckService.deleteRpBaseCheckById(id));
    }
}
